#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int tow(int x)
{
    if (x < 10)
    {
        return (x == 2) ? 1 : 0;
    }
    else {
        return (((x % 10) == 2) ? 1 : 0) + tow(x / 10);
    }
}

int main() {
    int n = 0, m = 0;
    scanf("%d%d", &n, &m);

    int count = 0;
    for (int i = n; i <= m; i++)
    {
        count += tow(i);
    }
    printf("%d", count);

    return 0;
}